<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <%--多附件上传css--%>
    <link rel="stylesheet" href="<s:url value="/assets/css/main.css"></s:url>"/>
    <style>
        body{
            background: #fff;
        }
        .SelectFiles{
            display: inline-block;
            position: absolute;
            font-size: 14px;
            color: #fff;
            left: 23px;
            top: 5px;
            width: 76px;
            height: 27px;
            background: #6FB3E0;
            text-align: center;
            border-radius: 5px;
            line-height: 25px;
            cursor: pointer;
        }
        button.btn{
            border-radius: 5px;
        }
        #laydate_today{
            display: none !important;
        }
        .select2-container .select2-choice{
            height: 34px;
            line-height: 34px;
            border-radius: 0px  !important;
        }
        .select2-container .select2-choice .select2-arrow b:before{
            left: 4px;
            top: -5px;
        }
        .btn-upload-file{
            display: none;
        }
        #qqqgridTable{
            width: 90%;
            margin: 0 auto;
        }
        .notclick{
            pointer-events: none;
        }
        .main-content{
            min-height: auto;
        }
    </style>
</head>
<body class="no-skin">
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>

<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div style="margin-top: 100px;">
                <form:form commandName="TaskMainFilter" cssClass="form-horizontal" role="form"  onsubmit="return false;">
                    <div class="row">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" style="text-align: left;margin-left: 8px;">
                                    任务名称
                                </label>
                                <div class="col-sm-8">
                                    <input type="text"  name="mainName"  placeholder="任务名称"  value="${TaskMainFilter.mainName}"
                                           class="form-control required">
                                </div>
                            </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-1 control-label no-padding-right" style="text-align: left;margin-left: 8px;">
                                任务内容
                            </label>
                            <div class="col-sm-8">
                                <textarea type="text" name="content" placeholder="任务内容"
                                       class="form-control required" style="resize: vertical;min-height: 50px;height: 80px">${TaskMainFilter.content}</textarea>
                            </div>
                        </div>
                    </div>
                   <!-- <div class="row ">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right" for="categoryId">
                                <a style="color: red">*</a>事项类型
                            </label>
                            <div class="col-sm-8">
                                <select type="text" id="categoryId" name="categoryId" placeholder="事项类型" readonly value="${TaskMainFilter.categoryId}"
                                       class="form-control required">
<%--                                    <c:forEach items="${types}" var="type">--%>
<%--                                        <option value="${type.category}">${type.category}</option>--%>
<%--                                    </c:forEach>--%>
                                </select>
                            </div>
                        </div>
                    </div> -->

                    <div class="row ">
                        <div class="form-group">
                            <label class="col-sm-1 control-label no-padding-right" style="text-align: left;margin-left: 8px;" >
                                事项类型
                            </label>
                            <div class="col-sm-8">
<%--                                <select name="" multiple="true" id="e1" onchange="addHandle(this)">--%>
                                    <input style="cursor: not-allowed" type="text" value="攻坚任务" disabled />
<%--                                    <select name="inspectionId"  disabled>--%>
<%--                                    <option value="攻坚任务">攻坚任务</option>--%>
<%--&lt;%&ndash;                                    <c:forEach items="${groups}" var="group">&ndash;%&gt;--%>
<%--&lt;%&ndash;                                        <option value="${group.sysId}">${group.deptName}</option>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                    </c:forEach>&ndash;%&gt;--%>
<%--                                </select>--%>
                                <input type="hidden" value=""  name="inspectionId">
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 10px">
                        <div class="form-group">
                           <label class="col-sm-1 text-right control-label" style="text-align: left;margin-left: 8px;">督办时限</label>
                           <div class="col-sm-4 ZtimeTypes">
                                 <input type="radio" onchange="Ztimetype(this)" name="timeType2" checked   value="1">单时限
                                 <input type="radio" onchange="Ztimetype(this)" name="timeType2"  value="2">周期性
                                  <input type="radio" onchange="Ztimetype(this)" name="timeType2"  value="3">多时限
                            </div>
                         </div>
                          <div class="ZchoiceTime">
                             <div class='form-group'>
                                 <label class="col-sm-1 text-right control-label" style="text-align: left;margin-left: 8px;">任务期限</label>
                                 <div class="col-sm-3">
                                       <input type="text" class="form-control Zdate_picker transform" name="timeLimit2" readonly>
                                 </div>
                             </div>
                          </div>
                          <div class="form-group">
                              <label class="col-sm-1 text-right control-label" style="text-align: left;margin-left: 8px;">子任务时限</label>
                              <div class="col-sm-4 ZtimeTypes">
                                  <input type="radio" onchange="Ztimetype2(this)" name="timeType" checked   value="1">单时限
                                  <input type="radio" onchange="Ztimetype2(this)" name="timeType"  value="2">周期性
                                  <input type="radio" onchange="Ztimetype2(this)" name="timeType"  value="3">多时限
                              </div>
                          </div>
                          <div class="ZchoiceTime2">
                              <div class='form-group'>
                                  <label class="col-sm-1 text-right control-label" style="text-align: left;margin-left: 8px;">任务期限</label>
                                  <div class="col-sm-3">
                                      <input type="text" class="form-control Zdate_picker transform" name="timeLimit" readonly>
                                  </div>
                              </div>
                        </div>

                        <div class="ZchoiceTime3">
                            <div class='form-group'>
                                <label class="col-sm-1 text-right control-label" style="text-align: left;margin-left: 8px;">轮次结束日期(选填)</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control Zdate_picker transform" name="planEndDate" readonly>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-1 text-right control-label" style="text-align: left;margin-left: 8px;">任务附件</label>
                            <div class="col-sm-8 pos-rel">
                                <div id="uploader"></div>
                                <%--<div>
                                    <div style="display: inline-block">
                                        <input type="file" class="fileBorder" id="fileupload">
                                    </div>
                                    <div style="display: inline-block">
                                        <button class="btn btn-info" onclick="uploadFile(this,'gJFile','gJFileName')">
                                            <span class="glyphicon glyphicon-open"></span>上传附件
                                        </button>
                                    </div>
                                </div>--%>
                            </div>
                        </div>
                    </div>
<%--                    <div class="row" style="margin-top: 100px">--%>
<%--                        <div class="form-group">--%>
<%--                            <label class="col-sm-2 control-label no-padding-right">--%>
<%--                            </label>--%>
<%--                            <div class="col-sm-6">--%>
<%--                                <input type="button" value="关闭" class="btn-sm btn-default pull-right" onclick="javascript: parent.close_current_app();" style="margin-left: 10px"/>--%>
<%--                                <input type="button" value="添加任务" class="btn-sm btn-info pull-right handleAdd" style="rgba(135, 184, 127)" onclick="handleAdd()"/>--%>
<%--                            </div>--%>
<%--                        </div>--%>
<%--                    </div>--%>
                    <%--多附件上传的name和id--%>
                    <input type="text" name="file" value="" hidden>
                    <input type="text" name="fileName" value="" hidden>
                </form:form>
                </div>
            </div>
        </div>
    </div>
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

<%--    <jsp:include page="/excel/data/gongjiantask " flush="true"/>--%>

    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
    <%@ include file="/WEB-INF/views/include/footer.jsp" %>
    <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
</div>

    <%--上传成功模态框--%>
    <div class="shade" style="display: none;"></div>
    <div class="warning" style="display: none;">
        <p class="title"><em></em><span class="close">X</span></p>
        <p class="cont"></p>
        <div class="la-square-jelly-box la-3x">
            <div></div>
            <div></div>
        </div>
    </div>
    <!-- /section:basics/navbar.layout -->
    <div class="main-container" id="main-container">
        <script type="text/javascript">
            try {
                ace.settings.check('main-container', 'fixed')
            } catch (e) {
            }
        </script>

        <!-- /section:basics/sidebar -->
        <div class="main-content">
            <div class="main-content-inner">
                <div class="page-content">
                    <!-- /section:settings.box -->
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="pull-left">
                                <!-- 权限按钮拦截部分 -->
                                <%-- <button class="btn btn-sm btn-pink" id="import">导入</button>--%>
                                <%--                            <button class="btn btn-sm btn-info" id="query">上传文件</button>--%>
                                <span>
                                批次号 <input type="text" readonly="readonly"  id="batch-nums" />
                            </span>
                                <button class="btn btn-sm btn-success" id="edit">修改</button>
                                <%--                            <button class="btn btn-sm btn-danger" id="delete">删除</button>--%>
                                <button class="btn btn-info upload-btn btn-sm"><span class="glyphicon glyphicon-floppy-save"></span>下载导入模板</button>
                                <input type="file" class="form-control" id="btn-Excel" style="display: none">
                                <button class="btn btn-info btn-sm" id="displayExcel" onclick="document.getElementById('btn-Excel').click()">
                                    导入子事项
                                </button>
                                <input type="button" value="确认导入" class="btn-sm btn-success btn pull-right handleAdd" style="background-color:rgba(135, 184, 127,1);border-radius: 5px;display: block;margin-left: 5px;margin-top: 2px" onclick="handleAdd()"/>
                                <%--                            <button class="btn btn-success btn-sm" id="displayExce2" onclick="displayExce2()">--%>
                                <%--                                确认保存--%>
                                <%--                            </button>--%>
                                <%--<button class="btn btn-info btn-sm" onclick="alert('用户角色选择填写主要领导、分管领导、经办人');window.open('/user/downUserModle/')">--%>
                                <%--下载用户模板--%>
                                <%--</button>--%>
                                <!-- 权限按钮拦截部分 -->
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="pull-left">
                                <div id="back-msg">校验信息：</div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <!-- PAGE CONTENT BEGINS -->
                            <!-- jqGrid表格 -->
                            <table id="gridTable"></table>
                            <!-- jqGrid工具类 -->
                            <div id="gridPager"></div>
                            <!-- 查询对话框 -->
                            <div style="display: none;">
                                <div class="row" id="queryDialog"></div>
                            </div>
                            <!-- PAGE CONTENT ENDS -->
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                </div><!-- /.page-content -->
            </div>
        </div><!-- /.main-content -->

        <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
            <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
        </a>

        <!-- dialog -->
        <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
    </div><!-- /.main-container -->

    <!-- footer -->
    <%@ include file="/WEB-INF/views/include/footer.jsp" %>

    <script type="text/javascript">

        /**
         * 状态格式化
         */
        function stateFormatter(data) {
            switch (data) {
                case '01':
                    return '未激活';
                    break;
                case '02':
                    return '正常';
                    break;
                case '03':
                    return '停用';
                    break;
                default:
                    return "无";
            }
        }

        //基本路径





        var baseUrl = "<s:url value="/excel/data/import"></s:url>/"

        //jqgrid的表格高度
        var height = 320;
        //jqgrid表格行头的中文
        var colNames = ['',  '校验标志','备注','事项','牵头单位','协办单位', '周期类型', '时限','督查组'];
        //jqgrid表格中每一行的信息模型
        var colModel = [
            {name: 'sysId', width: 60, hidden: true, key: true},
            {name: 'flags', index: 'flags', width: 50, editable: true,formatter:excelStateValue},
            {name: 'remarks', index: 'remarks', width: 100, editable: true},
            {name: 'cell0', index: 'cell0', width: 160, editable: true},
            {name: 'cell1', index: 'cell1', width: 60, editable: true},
            {name: 'cell2', index: 'cell2', width: 60, editable: true},
            {name: 'cell3', index: 'cell3', width: 60, editable: true},
            {name: 'cell4', index: 'cell4', width: 60, editable: true},
            {name: 'cell9', index: 'cell5', width: 60, editable: true},
            // {name: 'batchNum', index: 'batchNum', width: 60, editable: true}
        ];
        //jqgrid的具体执行方法
        jqgrid({
            gridTableId: "#gridTable",
            gridPagerId: "#gridPager",
            rowNum:50,
            multiselect:false,
            onSelectRow: function () {

            }

        });


        function excelStateValue(data) {
            switch (data){
                case 0:
                    return '校验不通过';
                    break;

                case 1:
                    return '校验通过';
                    break

                default:
                    return '无法校验';
            }
        }

        var rowids = [];//选中行id

        /**
         * 取消选中
         */
        function gridRemoveSelect(rowid) {
            rowids.remove(rowid);
        }

        /**
         * 添加选中
         */
        function gridAddSelect(rowid) {
            rowids.push(rowid);
        }

        //加载查询对话框
        //$("#queryDialog").load(getUrl("filter"));

        //重置表单
        function reset() {
            resetForm("#formDialog form");
        }

        //显示查询对话框
        var queryDialog = $("#queryDialog");
        $("#query").click(function () {
            showDialog({
                dialogTitle: '查询对话框',
                dialogBody: queryDialog,
                dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
                    "<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
                    "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
            });
        });

        //具体查询方法
        function query() {
            seachJqgird("#gridTable", "#formDialog form");
            $("#formDialog").modal('hide');
        }

        var uerpicihao = 0;
        //更新操作
        $("#edit").click(function () {
            $.ajax({
                url:'/excel/data/getFailList?batchNum='+batchNum,
                dataType:'json',
                type:'get',
                contentType:'application/json',
                success:function (res) {
                    if(res.data.failList.length>0){
                        uerpicihao = 0;
                        sessionStorage.setItem("thefailList",uerpicihao);
                        console.log(sessionStorage.getItem("thefailList"))
                        loadDialog({
                            dialogTitle: '数据校验',
                            dialogUrl:"/excel/data/showgjeditview?batchNum="+batchNum,
                            dialogFoot:
                                '<button type="button" class="btn btn-pink" onclick="edit()">提交更新</button>' +
                                '<button type="button" class="btn btn-primary" onclick="nextUpdate()">查看下一条</button>' +
                                '<button type="button" class="btn btn-default" data-dismiss="modal" onclick="guanbi()">关闭 </button>'
                        });
                    }else{
                        alert("未导入文本或当前暂无需要修改的内容！")
                    }
                }
            });
            /*showEditDialog({
                tableId: "#gridTable",
                dialogTitle: "更新对话框",
                dialogUrl: "/excel/data/edit/",
                dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()">更新</button>' +
                    // '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                    '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
                errorTitle: "消息对话框",
                errorMutiSelectMessage: '您当前选中多行，请重新选择',
                errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
                errorOk: '确定'
            });*/
        });
        function guanbi(){
            console.log("关闭："+uerpicihao);
            console.log("关闭："+batchNum);
            var searchData={batchNum:batchNum}
            seachJqgirdData("#gridTable",searchData);
        }
        /**
         * 点击下一条；
         */
        function nextUpdate() {
            uerpicihao++
            sessionStorage.setItem("thefailList",uerpicihao);
        }

        //执行更新操作
        function edit() {
            executeSaveOrUpdate2({
                formId: "#formDialog form",
                dialogId: "#formDialog",
                url: "/excel/data/edit/",
                tableId: "#gridTable",
                successMessage: "更新成功",
                successTitle: '更新提示框:',
                //  failMessage: '更新失败',
                // failFunc:showErrorDialog(obj),
                failTitle: '更新提示框:',
            });
        }
        //roomUser 查看或者 编辑 科室人员
        /* $("#roomUser").click(function () {
             showEditDialog({
                 tableId: "#gridTable",
                 dialogTitle: "更新对话框",
                 dialogUrl: getUrl("roomUser"),
                 dialogFoot: '<button type="button" class="btn btn-primary" onclick="updateRoonUser()">更新</button>' +
                     '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                     '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
                 errorTitle: "消息对话框",
                 errorMutiSelectMessage: '您当前选中多行，请重新选择',
                 errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
                 errorOk: '确定'
             });
         });*/

        /* function updateRoonUser() {
             executeSaveOrUpdate({
                 formId: "#formDialog form",
                 dialogId: "#formDialog",
                 url: getUrl("editroomuser"),
                 tableId: "#gridTable",
                 successMessage: "更新成功",
                 successTitle: '更新对话框',
                 failMessage: '更新失败',
                 failTitle: '消息对话框'
             });
         }*/

        //删除
        $("#delete").click(function () {
            showDeleteDialog({
                url: getUrl("delete"),
                tableId: "#gridTable",
                confirmTitle: "确认对话框",
                confirmMessage: "是否确定删除?",
                confirmOk: "确定",
                confirmCancel: "取消",
                successMessage: "删除成功",
                successTitle: "消息对话框",
                failTitle: "消息对话框",
                errorTitle: "警告提示框",
                errorMessage: "您当前尚未选中一行，请选择后再试",
                errorOk: "确定"
            });
        });

        //显示创建对话框
        $("#create").click(function () {
            loadDialog({
                dialogTitle: '创建对话框',
                dialogUrl: getUrl("create"),
                dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' +
                    '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                    '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
            });
        });

        //保存数据
        function create() {
            executeSaveOrUpdate({
                formId: "#formDialog form",
                dialogId: "#formDialog",
                url: getUrl("create"),
                tableId: "#gridTable",
                successMessage: "保存成功",
                successTitle: '保存对话框',
                failTitle: '消息对话框'
            });
        }


        //导入excel
        /**
         *  导入Excel
         */
        var batchNum;
        $(document).on('change', "#btn-Excel", function () {
            var $this = $(this);
            var slgBtn = $(this).siblings("#displayExcel")
            var file = $(this).val();
            var formData = new FormData();
            formData.append("excelFile", $("#btn-Excel")[0].files[0]);
            $('.warning').css("display","block")
            $('.shade').css("display","block")
            $(".shade").fadeIn(100);
            $(".warning").fadeIn(100);
            $('.la-square-jelly-box').show();
            showShade();
            //警告框自定义内容
            $('.warning>.title>em').html('加载中……');
            if (file) {
                $.ajax({
                    url: "/excel/data/importgjtask",
                    data: formData,
                    type: "post",
                    processData: false,
                    contentType: false,
                    success: function (data) {
                        console.log("导入操作返回数据")
                        console.log(data);
                        $('.warning>.title>em').html(data);
                        $this.remove();
                        slgBtn.before(
                            "<input type=\"file\" class=\"form-control\" id=\"btn-Excel\" style=\"display: none\">"
                        )
                        $("#batch-nums").val(data.data.batchNum);
                        console.log(data.data.batchNum)
                        var searchData ={batchNum:data.data.batchNum}
                        uerpicihao ={batchNum:data.data.batchNum}
                        batchNum=data.data.batchNum;
                        $("#back-msg").html("校验信息："+data.message)
                        seachJqgirdData("#gridTable",searchData);
                        setTimeout(function () {
                            $('.la-square-jelly-box').hide();
                            $('.warning').css("display","none")
                            $('.shade').css("display","none")
                        },500)
                    }
                });
            } else {
                alert("导入失败")
            }
        });
        //从部门到科室
        var deptId = '${deptId}';
        var deptName = '${deptName}';
        if (deptId != "") {
            //    alert("查看“" + deptName + "”的科室详情");
            window.onpageshow = function () {
                var url = '/sys/deptRoom';
                //先清空条件,多次调用时查询条件会累加
                $('#gridTable').jqGrid('clearGridData');
                $("#gridTable").jqGrid('setGridParam', {
                    url: url,
                    datatype: 'json',
                    postData: {'deptId': deptId}, //发送数据
                    page: 1
                }).trigger("reloadGrid"); //重新载入
            }
            $("#back").css("display","inline");
        }
        //返回部门
        $("#back").click(function () {
            window.location.href="/modules/sys/dept";
        });

    </script>
    <script>
        function displayExce2(){
            var r = confirm("提示：将保存校验通过的数据，校验不通过的数据不会被保存。确认保存吗？");
            if (r == true) {
                x = "您按了确认！";
                var batch_nums = document.getElementById("batch-nums").value
                if(batch_nums==""||batch_nums==undefined||batch_nums==NaN){
                    alert("请先导入文件！")
                }else{
                    console.log(batch_nums)
                }
            } else {
                x = "取消！";
            }
        }

        $(".upload-btn").on("click", function () {
            window.open("/taskMain/downModel?type=3");
        })

    </script>


<%--多选上传--%>
<script src="<s:url value="/assets/js/dist/easyUploader.jq.js"></s:url>"></script>
<%@ include file="/WEB-INF/views/include/footer.jsp" %>


    <script>

        //子任务时限
        function Ztimetype(e){
            var $checked = $(e).val();
            var html = ""
            if ($checked == 1){
                html =
                    "<div class='form-group'>" +
                    "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">任务期限</label>\n" +
                    "    <div class=\"col-sm-3\">\n" +
                    "        <input type=\"text\" class=\"form-control Zdate_picker transform\" name=\"timeLimit2\" readonly>\n" +
                    "    </div>\n" +
                    " </div>"
            }else if ($checked == 2){
                html =
                    '            <div class="form-group">\n' +
                    '                <label class="col-sm-offset-1 col-sm-1 text-right control-label">任务期限</label>\n' +
                    '                <div class="col-sm-3 Zperiods">\n' +
                    '                    <input type="radio" onchange="Zperiod(this)" name="period2" checked value="0">天\n' +
                    '                    <input type="radio" onchange="Zperiod(this)" name="period2"  value="1">周\n' +
                    '                    <input type="radio" onchange="Zperiod(this)" name="period2" value="2">月\n' +
                    '                    <input type="radio" onchange="Zperiod(this)" name="period2" value="3">季度\n' +
                    '                </div>\n' +
                    '                <label  class="col-sm-1 text-right control-label">反馈时限</label>\n' +
                    '                <div class="col-sm-3 ZfeedbackTime">\n' +
                    "                 <input type=\"number\" class=\"form-control\" min='0' name=\"day2\" placeholder=\"请输入天数\">\n"+
                    '               </div>\n' +
                    '            </div>'
            } else if ($checked ==3){
                html = "<div class='form-group'>" +
                    "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">任务时限</label>\n" +
                    "    <div class=\"col-sm-3\">\n" +
                    "        <input type=\"text\" placeholder=\"年-月-日\" class=\"form-control Zdate_picker danyan\" readonly>\n" +
                    "    </div>\n" +
                    "    <div class=\"col-sm-1 addTime\">\n" +
                    "        <input type=\"button\" class=\"btn btn-sm btn-success\" onclick='addTimeBtn(this)' value=\"添加时限\">\n" +
                    "        <input type=\"hidden\" name=\"timeLimits2\">\n" +
                    "    </div>\n" +
                    "    </div>"
            }
            $(e).parent().parent().parent().find('.ZchoiceTime').html(html)
        }

        //子任务时限
        function Ztimetype2(e){
            var $checked = $(e).val();
            var html = ""
            if ($checked == 1){
                html =
                    "<div class='form-group'>" +
                    "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">任务期限</label>\n" +
                    "    <div class=\"col-sm-3\">\n" +
                    "        <input type=\"text\" class=\"form-control Zdate_picker transform\" name=\"timeLimit\" readonly>\n" +
                    "    </div>\n" +
                    " </div>"
            }else if ($checked == 2){
                html =
                    '            <div class="form-group">\n' +
                    '                <label class="col-sm-offset-1 col-sm-1 text-right control-label">任务期限</label>\n' +
                    '                <div class="col-sm-3 Zperiods">\n' +
                    '                    <input type="radio" onchange="Zperiod2(this)" name="period" checked value="0">天\n' +
                    '                    <input type="radio" onchange="Zperiod2(this)" name="period"  value="1">周\n' +
                    '                    <input type="radio" onchange="Zperiod2(this)" name="period" value="2">月\n' +
                    '                    <input type="radio" onchange="Zperiod2(this)" name="period" value="3">季度\n' +
                    '                </div>\n' +
                    '                <label  class="col-sm-1 text-right control-label">反馈时限</label>\n' +
                    '                <div class="col-sm-3 ZfeedbackTime2">\n' +
                    "                 <input type=\"number\" class=\"form-control\" min='0' name=\"day\" placeholder=\"请输入天数\">\n"+
                    '               </div>\n' +
                    '            </div>'
            } else if ($checked ==3){
                html = "<div class='form-group'>" +
                    "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">任务时限</label>\n" +
                    "    <div class=\"col-sm-3\">\n" +
                    "        <input type=\"text\" placeholder=\"年-月-日\" class=\"form-control Zdate_picker danyan2\" readonly>\n" +
                    "    </div>\n" +
                    "    <div class=\"col-sm-1 addTime\">\n" +
                    "        <input type=\"button\" class=\"btn btn-sm btn-success\" onclick='addTimeBtn2(this)' value=\"添加时限\">\n" +
                    "        <input type=\"hidden\" name=\"timeLimits\">\n" +
                    "    </div>\n" +
                    "    </div>"
            }
            $(e).parent().parent().parent().find('.ZchoiceTime2').html(html)
        }

        function Zperiod(e){
            var $checked = $(e).val();
            var html = ""
            if ($checked == 0){
                html = "        <input type=\"number\" class=\"form-control\" min='0' name=\"day2\" placeholder=\"请输入天数\">\n"
            }
            else if ($checked == 1){
                html = "      <select name=\"week2\" class=\"form-control\">\n" +
                    "            <option value=\"1\">星期一</option>\n" +
                    "            <option value=\"2\">星期二</option>\n" +
                    "            <option value=\"3\">星期三</option>\n" +
                    "            <option value=\"4\">星期四</option>\n" +
                    "            <option value=\"5\">星期五</option>\n" +
                    "            <option value=\"6\">星期六</option>\n" +
                    "            <option value=\"7\">星期日</option>\n" +
                    "        </select>"
            } else if ($checked == 2){
                html = "<input type=\"text\" id=\"\" value=\"\" readonly lay-verify=\"date\" name=\"month2\" placeholder=\"日\" autocomplete=\"off\" class=\"layui-input dalong form-control\">\n"
            }else if($checked == 3){
                html = "    <input type=\"text\" value=\"\" readonly lay-verify=\"date\" placeholder=\"年-月-日\" name=\"quarter2\" autocomplete=\"off\" class=\"layui-input form-control date_picker\">\n"
            }
            $(e).parent().parent().parent().find(".ZfeedbackTime").html(html);
        }
        function Zperiod2(e){
            var $checked = $(e).val();
            var html = ""
            if ($checked == 0){
                html = "        <input type=\"number\" class=\"form-control\" min='0' name=\"day\" placeholder=\"请输入天数\">\n"
            }
            else if ($checked == 1){
                html = "      <select name=\"week\" class=\"form-control\">\n" +
                    "            <option value=\"1\">星期一</option>\n" +
                    "            <option value=\"2\">星期二</option>\n" +
                    "            <option value=\"3\">星期三</option>\n" +
                    "            <option value=\"4\">星期四</option>\n" +
                    "            <option value=\"5\">星期五</option>\n" +
                    "            <option value=\"6\">星期六</option>\n" +
                    "            <option value=\"7\">星期日</option>\n" +
                    "        </select>"
            } else if ($checked == 2){
                html = "<input type=\"text\" id=\"\" value=\"\" readonly lay-verify=\"date\" name=\"month\" placeholder=\"日\" autocomplete=\"off\" class=\"layui-input dalong form-control\">\n"
            }else if($checked == 3){
                html = "    <input type=\"text\" value=\"\" readonly lay-verify=\"date\" placeholder=\"年-月-日\" name=\"quarter\" autocomplete=\"off\" class=\"layui-input form-control date_picker\">\n"
            }
            $(e).parent().parent().parent().find(".ZfeedbackTime2").html(html);
        }
        function addTimeBtn(e) {
            var html = " <div class=\"form-group \">" +
                "        <label class=\"col-sm-offset-1 col-sm-1 text-right control-label redTips\">任务时限</label>\n" +
                "   <div class=\"col-sm-3\">\n" +
                "       <input type=\"text\" value=\"\" readonly lay-verify=\"date\" placeholder=\"年-月-日\" autocomplete=\"off\" class=\"layui-input form-control date_picker danyan\">\n" +
                "</div>\n" +
                "    <div class=\"col-sm-1 addTime\">\n" +
                "        <input type=\"button\" class=\"btn btn-sm btn-danger removeTimeBtn\"  value=\"删除时限\">\n" +
                "    </div>"
            "</div>"
            $(e).parent().parent().parent().append(html);
        }
        function addTimeBtn2(e) {
            var html = " <div class=\"form-group \">" +
                "        <label class=\"col-sm-offset-1 col-sm-1 text-right control-label redTips\">任务时限</label>\n" +
                "   <div class=\"col-sm-3\">\n" +
                "       <input type=\"text\" value=\"\" readonly lay-verify=\"date\" placeholder=\"年-月-日\" autocomplete=\"off\" class=\"layui-input form-control date_picker danyan2\">\n" +
                "</div>\n" +
                "    <div class=\"col-sm-1 addTime\">\n" +
                "        <input type=\"button\" class=\"btn btn-sm btn-danger removeTimeBtn\"  value=\"删除时限\">\n" +
                "    </div>"
            "</div>"
            $(e).parent().parent().parent().append(html);
        }
    </script>
<script>
    <%--多文件上传--%>
    var fileStr = "";//id字符串拼接
    var fileNameStr = "";//文件名字符串拼接
    var uploader = easyUploader({
        id: "uploader",
        accept: '.jpg,.png,.doc,.docx,.pdf,.xls,.xlsx,.ppt,.pptx',
        action: '/filesUpload/uploadFiles',
        dataFormat: 'formData',
        maxCount: 10,//允许上传的个数
        maxSize: 2000,//允许上传最大的容量
        multiple: true,
        data: null,
        beforeUpload: function (file, data, args) {
        },
        onChange: function (fileList) {
        },
        onRemove: function (removedFiles, files) {
            console.log('onRemove', removedFiles);
        },
        onSuccess: function (res) {
            console.log('onSuccess', res);
            if (res.data !== undefined && res.data[0] !== undefined) {
                //拼接文件id 和 文件名
                $("input[name='file']").val(fileStr += res.data[0].sysid + ",");
                $("input[name='fileName']").val(fileNameStr += res.data[0].oldName + ",");

            }
        },
        onError: function (err) {
            console.log('onError', err);
        },
    });
</script>
    <script>
        function minDate() {
            var now = new Date();
            return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + (now.getDate() + 1);
        }
        $(document).ready(function (){
            $(document).on("click",".date_picker",function () {
                laydate({
                    elem: this,
                    min: minDate(),
                    choose:function (taskTime) {  //单时限  日期换天数
                        //获取到当天日期
                        var date = new Date();
                        var seperator1 = "-";
                        var year = date.getFullYear();
                        var month = date.getMonth() + 1;
                        var strDate = date.getDate();
                        if (month >= 1 && month <= 9) {
                            month = "0" + month;
                        }
                        if (strDate >= 0 && strDate <= 9) {
                            strDate = "0" + strDate;
                        }
                        var currentdate = year + seperator1 + month + seperator1 + strDate;
                        // console.log(currentdate);
                        // console.log55555

                        //获取任务时限的val值 计算出任务与时限相差几天
                        var disparity = ((new Date(taskTime)/1000) - (new Date(currentdate)/1000))/(60*60*24);
                        $("#date_picker_jy").val(disparity);
                    }
                });
            });
            $(document).on("click",".Zdate_picker",function () {
                laydate({
                    elem: this,
                    min: minDate(),
                });
            });
            $(document).on("click",".DBdate_picker",function () {
                laydate({
                    elem: this,
                    min: minDate(),
                    choose:function (taskTime) {  //单时限  日期换天数
                        //获取到当天日期
                        var date = new Date();
                        var seperator1 = "-";
                        var year = date.getFullYear();
                        var month = date.getMonth() + 1;
                        var strDate = date.getDate();
                        if (month >= 1 && month <= 9) {
                            month = "0" + month;
                        }
                        if (strDate >= 0 && strDate <= 9) {
                            strDate = "0" + strDate;
                        }
                        var currentdate = year + seperator1 + month + seperator1 + strDate;
                        // console.log(currentdate);
                        // console.log55555

                        //获取任务时限的val值 计算出任务与时限相差几天
                        var disparity = ((new Date(taskTime)/1000) - (new Date(currentdate)/1000))/(60*60*24);
                        $("#DBdate_picker_jy").val(disparity);
                    }
                });
            });
            $(document).on("click","#date_picker",function () {
                laydate({
                    elem: this,
                    format: 'YYYY-MM-DD',
                    // min: minDate(),
                    choose: function(data){
                        //将值赋值给input框
                        console.log(data)
                        var $checked = $("input[name='period']:checked").val();
                        data = data.substring(data.length-2,data.length)
                        $("#date_picker").val(data);
                    }
                });
            });


            $(document).on("click",".dalong",function () {
                var _this = this;
                laydate({
                    // elem: ".dalong",
                    elem: this,
                    format: 'YYYY-MM-DD',
                    // min: minDate(),
                    choose: function(data){
                        //将值赋值给input框
                        console.log(data)
                        var $checked = $("input[name='period']:checked").val();
                        data = data.substring(data.length-2,data.length)
                        $(_this).val(data);
                    }
                });
            });
            // var Zdate_pickers = document.querySelectorAll(".Zdate_picker")
            // for(let i=0;i<Zdate_pickers.length;i++){
            //     Zdate_pickers[i].onclick = function(data){
            //         console.log(data)
            //         console.log(Zdate_pickers[i])
            //     }
            // }
            $(document).on("click","#DBdate_picker",function () {
                laydate({
                    elem: "#DBdate_picker",
                    format: 'YYYY-MM-DD',
                    // min: minDate(),
                    choose: function(data){
                        //将值赋值给input框
                        var $checked = $("input[name='period2']:checked").val();
                        data = data.substring(data.length-2)
                        $("#DBdate_picker").val(data);
                    }
                });
            });
        });
    </script>
<script type="text/javascript">
    // $(document).ready(function () {
    //     $("#e1").select2({
    //         placeholder: "请输入或点击选择督察组",
    //         width: "100%",
    //         closeOnSelect: false,
    //         allowClear: true,
    //     });
    // });
    // function addHandle(data) {
    //     $(data).siblings("input").val($(data).val().join(","));
    // }

    function handleAdd() {
        failure(".handleAdd",1)
        var inspectionId = $("input[name='inspectionId']").val()
        var content = $("textarea[name='content']").val()
        var mainName = $("input[name='mainName']").val()
        var file = $("input[name=file]").val()
        var gJFileName = $("input[name=fileName]").val()
        console.log(inspectionId,content,mainName)

        var value = []
        var value2 = []
        var DBvalue = []
        $(".danyan").each(function() {
            value.push($(this).val());
        });
        $(".danyan2").each(function() {
            value2.push($(this).val());
        });
        value = value.join(",");
        value2 = value2.join(",");
        $("input[name='timeLimits2']").val(value)
        $("input[name='timeLimits']").val(value2)

        var   timeLimit2 =  $("input[name='timeLimit2']").val()
        var   timeType2 =  $("input[name='timeType2']").val()
        var   period2 =  $("input[name='period2']").val()
        var   day2 =  $("input[name='day2']").val()
        var   week2 =  $("select[name='week2']").val()
        var   month2 =  $("input[name='month2']").val()
        var   quarter2 =  $("input[name='quarter2']").val()
        var   timeLimits2 =  $("input[name='timeLimits2']").val()

        var   timeLimit =  $("input[name='timeLimit']").val()
        var   timeType =  $("input[name='timeType']").val()
        var   period =  $("input[name='period']").val()
        var   day =  $("input[name='day']").val()
        var   week =  $("select[name='week']").val()
        var   month =  $("input[name='month']").val()
        var   quarter =  $("input[name='quarter']").val()
        var   timeLimits =  $("input[name='timeLimits']").val()

        var planEndDate= $("input[name='planEndDate']").val()

        $.post("/taskCrucial/creategj",{
            "mainName":mainName,
            "content":content,
            // "inspectionId":inspectionId,
            "gJFile":file,
            "gJFileName":gJFileName,
            "timeLimit2":timeLimit2,
            "timeType2":timeType2,
            "period2":period2,
            "day2":day2,
            "week2":week2,
            "month2":month2,
            "quarter2":quarter2,
            "timeLimits2":timeLimits2,
            "timeLimit":timeLimit,
            "timeType":timeType,
            "period":period,
            "day":day,
            "week":week,
            "month":month,
            "quarter":quarter,
            "timeLimits":timeLimits,
            "planEndDate":planEndDate
        },function (res) {
            if(res){
                if(res.code == '200'){
                    alert('添加成功')
                    setTimeout(function () {
                        parent.close_current_app();
                    },50)
                } else {
                    alert('添加失败：'+ res.message)
                }
                failure(".handleAdd",0)
            }
        })
    }
    function rightTipBOX(msg) {
        if(msg == undefined){
            msg = ''
        }
        $.gritter.add({
            title: "提示",
            text: msg
        });
    }
</script>
</body>
</html>
